<!DOCTYPE html>

<html>

<head>
    <meta charset="utf-8">
    <title>入库数据记录</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
    <link rel="stylesheet" href="//at.alicdn.com/t/font_739294_4v71dzenelg.css" media="all">
    <link rel="stylesheet" href="../../layuiadmin/layui/css/my.css" media="all">
</head>

<body>
    <div class="layui-form" style="margin-left:20px;margin-top:15px;margin-bottom:-20px">
        <div class="layui-form-item">
            <label class="layui-form-label">入库日期：</label>
            <div class="layui-inline">
                <input type="text" class="layui-input" id="datetime" autocomplete="off" placeholder="请选择日期">
            </div>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;医院名称：
            <div class="layui-inline" style="width:300px">
                <select name="hid" id="select" style="width:300px" class="layui-input" lay-search>
                    <option value=""></option>
                </select>
            </div>
            <div class="layui-btn-group">
                <button class="layui-btn layui-btn-normal" data-type="reload" id="serch"> <i class="layui-icon">&#xe615;</i>查询</button>
            </div>
        </div>
    </div>
    <table id="demo" lay-filter="test"></table>
    <script src="../../layuiadmin/layui/layui.js"></script>
    <script src="../../layuiadmin/layui/jquery-3.3.1.min.js"></script>
    <script src="../../layuiadmin/layui/action.js"></script>

    <script>
        layui.config({
            base: '../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index']);
        layui.use('laydate', function() {
            var laydate = layui.laydate;

            //执行一个laydate实例
            laydate.render({
                elem: '#datetime', //指定元素
                theme: "#1E9FFF"
            });
        });
        layui.use('table', function() {
            var table = layui.table;
            var $ = layui.$;
            var tableIns = table.render({
                elem: '#demo',
                height: 'full-75',
                data: [],
                totalRow: true,
                cols: [
                    [ //表头
                        {
                            field: 'hospname',
                            title: '医院名称',
                            width: "8%",
                            align: 'center',
                            event: 'info'
                        }, {
                            field: 'ctime',
                            title: '入库时间',
                            align: 'center',
                            width: "10%",
                        }, {
                            field: 'cname',
                            title: '收集人员',
                            align: 'center',
                            width: "8%",
                        }, {
                            field: 'sname',
                            title: '入库审核人员',
                            width: "8%",
                            totalRowText: "合计"
                        }, {
                            field: 'totalweight',
                            title: '总重量',
                            width: "8%",
                            align: 'center',
                            totalRow: true
                        }, {
                            field: 'weight_0',
                            title: '感染性重量',
                            width: "8%",
                            align: 'center',
                            totalRow: true
                        }, {
                            field: 'weight_1',
                            title: '损伤性重量',
                            width: "8%",
                            align: 'center',
                            totalRow: true
                        }, {
                            field: 'weight_5',
                            title: '病理性重量',
                            width: "8%",
                            align: 'center',
                            totalRow: true
                        }, {
                            field: 'weight_4',
                            title: '药物性重量',
                            width: "8%",
                            align: 'center',
                            totalRow: true
                        }, {
                            field: 'weight_3',
                            title: '化学性重量',
                            width: "8%",
                            align: 'center',
                            totalRow: true
                        }, {
                            field: 'weight_2',
                            title: '输液瓶重量',
                            width: "8%",
                            align: 'center',
                            totalRow: true
                        }, {
                            field: 'weight_7',
                            title: '输液袋重量',
                            width: "8%",
                            align: 'center',
                            totalRow: true
                        }
                    ]
                ],
                skin: 'row' //表格风格
                    ,
                even: true,
                totalRow: true
            });
            $("#serch").on('click', function() {
                tableIns.reload({
                    url: '../../../Collect/UnloadSum',
                    where: {
                        date: $("#datetime").val(),
                        hid: $("#select option:selected").val()
                    }, //设定异步数据接口的额外参数
                });
            });
            table.on('tool(test)', function(obj) {
                var d = obj.data;
                if (obj.event === 'info') {
                    layer.open({
                        type: 2,
                        area: area(1030, 960),
                        offset: 'auto',
                        title: ['入库详细信息', 'background:#1E9FFF;color:white;font-size:17px;font-weight:bold'],
                        content: 'information/unloadinfo.html',
                        maxmin: true,
                        success: function(layero, index) {
                            var body = layer.getChildFrame('body', index);
                            body.find('#uid').html(d.uid);
                            body.find('#sname').html(d.sname);
                            body.find('#cname').html(d.cname);
                            body.find('#ctime').html(d.ctime);
                            body.find('#total').html(d.total + ' 箱');
                            body.find('#totalweight').html(d.totalweight + ' 公斤');
                            body.find('#num_0').html(d.num_0 + " 箱"); //感染性
                            body.find('#num_1').html(d.num_1 + " 箱"); //损伤性
                            body.find('#num_5').html(d.num_5 + " 箱"); //病理性
                            body.find('#num_4').html(d.num_4 + " 箱"); //药物性
                            body.find('#num_2').html(d.num_2 + " 袋"); //输液瓶
                            body.find('#num_3').html(d.num_3 + " 袋"); //化学性
                            body.find('#num_7').html(d.num_7 + " 袋"); //输液袋
                            body.find('#nval1_2').html(d.nval1_2 + " 袋"); //利器盒
                            body.find('#nval1_5').html(d.nval1_5 + " 袋"); //胎盘
                            body.find('#weight_0').html(parseFloat(isZero(d.weight_0)) + " 公斤");
                            body.find('#weight_1').html(parseFloat(isZero(d.weight_1)) + " 公斤");
                            body.find('#weight_2').html(parseFloat(isZero(d.weight_2)) + " 公斤");
                            body.find('#weight_3').html(parseFloat(isZero(d.weight_3)) + " 公斤");
                            body.find('#weight_4').html(parseFloat(isZero(d.weight_4)) + " 公斤");
                            body.find('#weight_5').html(parseFloat(isZero(d.weight_5)) + " 公斤");
                            body.find('#weight_7').html(parseFloat(isZero(d.weight_7)) + " 公斤");
                        }
                    })
                }
            });
            table.on('rowDouble(test)', function(obj) {
                var d = obj.data;
                layer.open({
                    type: 2,
                    area: area(1030, 960),
                    offset: 'auto',
                    title: ['入库详细信息', 'background:#1E9FFF;color:white;font-size:17px;font-weight:bold'],
                    content: 'information/unloadinfo.html',
                    maxmin: true,
                    success: function(layero, index) {
                        var body = layer.getChildFrame('body', index);
                        body.find('#uid').html(d.uid);
                        body.find('#sname').html(d.sname);
                        body.find('#cname').html(d.cname);
                        body.find('#ctime').html(d.ctime);
                        body.find('#total').html(d.total + ' 箱');
                        body.find('#totalweight').html(d.totalweight + ' 公斤');
                        body.find('#num_0').html(d.num_0 + " 箱"); //感染性
                        body.find('#num_1').html(d.num_1 + " 箱"); //损伤性
                        body.find('#num_5').html(d.num_5 + " 箱"); //病理性
                        body.find('#num_4').html(d.num_4 + " 箱"); //药物性
                        body.find('#num_2').html(d.num_2 + " 袋"); //输液瓶
                        body.find('#num_3').html(d.num_3 + " 袋"); //化学性
                        body.find('#num_7').html(d.num_7 + " 袋"); //输液袋
                        body.find('#nval1_2').html(d.nval1_2 + " 袋"); //利器盒
                        body.find('#nval1_5').html(d.nval1_5 + " 袋"); //胎盘
                        body.find('#weight_0').html(parseFloat(isZero(d.weight_0)) + " 公斤");
                        body.find('#weight_1').html(parseFloat(isZero(d.weight_1)) + " 公斤");
                        body.find('#weight_2').html(parseFloat(isZero(d.weight_2)) + " 公斤");
                        body.find('#weight_3').html(parseFloat(isZero(d.weight_3)) + " 公斤");
                        body.find('#weight_4').html(parseFloat(isZero(d.weight_4)) + " 公斤");
                        body.find('#weight_5').html(parseFloat(isZero(d.weight_5)) + " 公斤");
                        body.find('#weight_7').html(parseFloat(isZero(d.weight_7)) + " 公斤");
                    }
                })
            });
            $.ajax({
                url: "../../../Cust/hospital",
                dataType: 'json',
                type: "get",
                success: function(res) {
                    $.each(res.data, function(index) {
                        var id = res.data[index].hid;
                        var name = res.data[index].name;
                        $("#select").append("<option value='" + id + "'>" + name + "</option>")
                    });
                    layui.form.render();
                }

            })
        });
    </script>

</body>

</html>